#include<bits/stdc++.h>

using namespace std;

int main() {
    double N;
    int T;
    cin >> T;
    while (T--) {
        cin >> N;
        double x = N * log10(N);
        x -= (long long) x;
        cout << (int) pow(10, x) << endl;
    }

    return 0;
}